perm filename MFFIL.SAI[MF,DEK]2 blob
sn#492167 filedate 1980-01-17 generic text, type T, neo UTF8
comment This page contains the most TENEX-dependent aspects
of the METAFONT input routines for TENEX installations;
internal saf string array fname[0:2] # file directory, name, and extension;
internal simp procedure scanfilename # sets up fname[0:2];
begin integer j,c,cc;
fname[0]←fname[1]←fname[2]←null;
j←1;
while curbuf and chartype[curbuf]=space do c←lop(curbuf);
loop begin cc←chartype[c←lop(curbuf)];
if c="." then j←2
else if c="<" then j←0
else if c=">" then j←0
else begin
case cc of begin
[wxy][digit][letter] ;
else done end;
end;
fname[j]←fname[j]&c;
if c=">" then j←1;
end;
end;
procedure inputfile;
begin comment "input" has just been scanned. This procedure scans
the user's file name, employing the TENEX naming conventions, then reads
in the first line and feeds it to the input system;
integer chan;
label abort # if something goes wrong trying to read the file;
label retry # go here to try again;
boolean firsttry # first attempt to read the file;
string flname;
integer pageno # number of pages successfully read;
define checkeof=⊂if eof then begin print(")");go to abort end⊃;
firsttry←true; retry:
scanfilename;
if noinput then return;
if fname[2]=0 then fname[2]←".mf" # default extension;
flname←fname[0]&fname[1]&fname[2];
open(chan←getchan,"DSK",0,1,0,4000,brchar,eof) # input, no output;
lookup(chan,flname,eof);
comment if lookup failed and no explicit directory was given, try <SP>;
if eof and fname[0]=0 then
begin comment if lookup failed and no explicit directory was given,
try default directory <SP>;
flname←"<SP>"&flname;
lookup(chan,flname,eof);
end;
if eof then
begin error("Lookup failed on file "&flname);
if firsttry then
begin firsttry←false; release(chan); go to retry;
end;
go to abort;
end;
print(" (",flname);
pushinput # save present file status;
recovery←chan; filename←flname;
inbuf←input(chan,crffbreak) # get first line of file;
checkeof; print(" 1");
if equ(inbuf[1 to 9],"COMMENT ⊗") then
begin comment Skip TVedit directory page;
while brchar≠'14 and not eof do inbuf←input(chan,ffbreak);
checkeof;
inbuf←input(chan,crffbreak) # get first line of second page;
checkeof; print(" 2");
pageno←2;
end
else pageno←1;
while brchar='14 do
begin comment Ignore empty pages at the beginning of file;
inbuf←input(chan,crffbreak); checkeof; pageno←pageno+1;
print(" ",pageno);
end;
loc ← (pageno lsh infod) + 1 # line 1 of the current page;
if pausing then
begin integer p # garbage bin;
if inbuf='12 then p←lop(inbuf);
if length(inbuf)=1 then inbuf←" "&inbuf;
print(nextline);
outstr(inbuf[1 to ∞-1]) # show inbuf on screen;
begin string s; s←inchwl;
if s then inbuf←s&inbuf[∞ to ∞];
end;
end;
curbuf←inbuf;
comment Now define the output file name if it hasn't yet been defined;
if ofilname=0 then
begin ofilname←fname[1]; comment ofilarea←fname[0];
end;
return;
abort: release(chan);
popinput;
end;